#ifndef WEATHER_H
#define WEATHER_H
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QByteArray>
#include <QDialog>
#include <QPainter>
#include <QMenu>
#include <QAction>
#include <QMouseEvent>
#include <QDebug>
#include <QPoint>
#include <QLabel>
#include "WeatherTool.h"
#include <QMessageBox>
#include "Weatherdata.h"
#include <QTimer>
QT_BEGIN_NAMESPACE
namespace Ui { class Weather; }
QT_END_NAMESPACE



class Weather : public QDialog
{
    Q_OBJECT

public:
    Weather(QWidget *parent = nullptr);
    ~Weather();
protected:
    void contextMenuEvent(QContextMenuEvent *menuEvent);
    void mouseMoveEvent(QMouseEvent *event);
    void mousePressEvent(QMouseEvent *event);
    bool eventFilter(QObject *watched, QEvent *event);
private slots:
    void slot_exitApp();
    void replayFinished(QNetworkReply *reply);
    void on_searchBt_clicked();

    void on_refreshBt_clicked();

private:
    void getWeatherInfo(QNetworkAccessManager *manager);
    void parseJson(QByteArray& bytes);
    void setLabelContent();
    void paintSunRiseSet();
    void paintCurve();
private:
    Ui::Weather *ui;
    QMenu *m_pMenu;
    QAction *m_pExitAct; //退出的行为
    QPoint m_Pos; //窗口移动


    QList<QLabel *> forecast_week_list;         //星期
    QList<QLabel *> forecast_date_list;         //日期
    QList<QLabel *> forecast_aqi_list;          //天气指数
    QList<QLabel *> forecast_type_list;         //天气
    QList<QLabel *> forecast_typeIco_list;      //天气图标
    QList<QLabel *> forecast_high_list;         //高温
    QList<QLabel *> forecast_low_list;          //低温


    static const QPoint sun[2];
    static const QRect sunRizeSet[2];
    static const QRect rect[2];

    QTimer *sunTimer;
private:
    QNetworkAccessManager *manager;
    QString url;
    QString city;
    QString cityTmp;  //临时存放城市变量 防止输入错误的时候  原来的城市名称还存在
    WeatherTool tool;

    //本地数据
    Today today;
    Forecast forecast[6];


};
#endif // WEATHER_H
